package com.qianfeng.teachdemo.ui.touch.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.LinearLayout;

import com.lidroid.xutils.util.LogUtils;

/**
 * @ClassName: com.qianfeng.qianfengteachdemo.ui.touch.widget
 * @Description:
 * @author: zhangwei
 * @data: 2014-11-11 下午2:12
 * @version: V1.0
 */
public class MyLayout extends LinearLayout {
    public static final String TAG = "MyLayout";

    public MyLayout(Context context) {
        super(context);
    }

    public MyLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    /**
     * 事件分发
     *
     * @param event
     * @return
     */
    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                LogUtils.e(TAG + "------->>>dispatchTouchEvent" + ":ACTION_DOWN");
                break;
            case MotionEvent.ACTION_MOVE:
                LogUtils.e(TAG + "------->>>dispatchTouchEvent" + ":ACTION_MOVE");
                break;
            case MotionEvent.ACTION_UP:
                LogUtils.e(TAG + "------->>>dispatchTouchEvent" + ":ACTION_UP");
                break;
        }
        return super.dispatchTouchEvent(event);
    }


    /**
     * 事件处理
     */

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.e(TAG, "onTouchEvent");
        return super.onTouchEvent(event);
    }

    /**
     *
     * 事件拦截分三种情况
     * 返回 super.onInterceptTouchEvent(ev) 系统默认会拦截,并且交个当前的View的onTouchEvent去处理
     *
     *
     *
     * 事件拦截
     * @param ev
     * @return
     */
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                break;
            case MotionEvent.ACTION_MOVE:
                break;
            case MotionEvent.ACTION_UP:
                break;
        }
        return super.onInterceptTouchEvent(ev);
    }




}
